package cn.ly.array;

public class ArrayApp {
	
	public static void main(String[] args) {
		long[] arr;
		arr = new long[100];
		int nElems = 0;
		int j;
		long searchKey;
		
		arr[0] = 77;
		arr[1] = 99;
		arr[2] = 44;
		arr[3] = 55;
		arr[4] = 22;
		arr[5] = 88;
		arr[6] = 11;
		arr[7] = 0;
		arr[8] = 66;
		arr[9] = 33;
		nElems = 10;
		
		
		//显示所有
		for(j=0; j < nElems; j++){
			System.out.print(arr[j]+" ");
		}
		System.out.println();
		
		j = 0;
		/*for(long key : arr){
			j++;
			if(key == searchKey){
				break;
			}
		}*/
		
		//查找一个元素
		searchKey = 66;
		for(j=0; j < 10; j++){
			if(arr[j] == searchKey){
				break;
			}
		}
		if(j == 10){
			System.out.println("Can't find " + searchKey);
		}else{
			System.out.println("Found " + searchKey + " at arr[" + j + "]");
		}
		
		//删除一个元素
		searchKey = 55;
		for(j = 0; j < nElems; j++){
			if(searchKey == arr[j]){
				break;
			}
		}
		for( ;j < nElems; j++){
			arr[j] = arr[j+1];
		}
		nElems = 9;
		
		//再显示所有
		for(j = 0; j < nElems; j++){
			System.out.print(arr[j] + " ");
		}
		
	}

}
